package com.spdbcc;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class PersonTest {

    public static void main(String[] args) {
        List<Person> list = new ArrayList();
        list.add(new Person(1, "guor"));
        list.add(new Person(2, "xiaoxia"));
        list.add(new Person(3, "xiaotong"));
        Collector<Person, ?, Map<Integer, String>> personMapCollector = Collectors.toMap(Person::getId, Person::getName);
        System.out.println(personMapCollector);
        Map<Integer, String> map = list.stream().collect(Collectors.toMap(Person::getId, Person::getName));
        System.out.println(map);
    }
}
